
#include <stddef.h>           /* needed for definition of NULL */
#include <stdio.h>
#include "Common.h"
#include "LCD.h"
#include "Gdi.h"

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/
/*********************************************************************
*
*       _DispLine
*/
static void _DispLine(const char *s, int MaxNumChars, const GUI_RECT *pRect)
{
    WORD Char;
    if (GUI_Context.pAFont->pafEncode) {
        GUI_Context.pAFont->pafEncode->pfDispLine(s, MaxNumChars);
    }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       GUI__GetLineNumChars
*/
int GUI__GetLineNumChars(const char *s, int MaxNumChars)
{
    int NumChars = 0;

    if (s)
    {
        if (GUI_Context.pAFont->pafEncode) {
            return GUI_Context.pAFont->pafEncode->pfGetLineLen(s, MaxNumChars);
        }
    }

    return NumChars;
}

/*********************************************************************
*
*       GUI__GetLineDistX
*
*  This routine is used to calculate the length of a line in pixels.
*/
int GUI__GetLineDistX(const char *s, int MaxNumChars)
{
    int Dist;

    Dist = 0;
    if (s)
    {
        WORD Char;

        if (GUI_Context.pAFont->pafEncode) {
            return GUI_Context.pAFont->pafEncode->pfGetLineDistX(s, MaxNumChars);
        }
    }

    return Dist;
}

/*********************************************************************
*
*       GUI__DispLine
*/
void GUI__DispLine(const char *s, int MaxNumChars, const GUI_RECT* pr)
{
    GUI_RECT r;


    r = *pr;

    GUI_Context.DispPosX = r.x0;
    GUI_Context.DispPosY = r.y0;
    /* Do the actual drawing via routine call. */
    _DispLine(s, MaxNumChars, &r);
}

/*************************** End of file ****************************/
